import os
import cv2
import utils
from tqdm import tqdm


SrcDir = r"I:\Temp\Temp3"
DstDir = r"I:\Temp\Temp5"
NewW = 320
NewH = 320
NameStart = 0

for root, dirs, files in os.walk(SrcDir):
    for file in tqdm(files):
        if file[-1] == 'l':
            NameStart += 1
            Infos = utils.ReadXml(root + "\\" + file)
            img = cv2.imread(root + "\\" + file[:-3] + "jpg")
            img, Infos = utils.ResizeJpgAndXml(img, Infos, NewW, NewH)
            NewInfos = [DstDir + "/%05d.xml" % NameStart] + Infos
            cv2.imwrite(DstDir + "/%05d.jpg" % NameStart, img)
            utils.WriteXml(NewInfos, NewW, NewH)
